package main

import (
	"fmt"
	"os"
	"time"
)

const birthTime = "2006-01-02 15:04:05"

func main() {
	timer := time.NewTimer(1 * time.Second)
	fmt.Println("now is " + time.Now().Format(birthTime))
	<-timer.C
	fmt.Println("now is " + time.Now().Format(birthTime))
	<-time.After(2 * time.Second)
	fmt.Println("now is " + time.Now().Format(birthTime))
	timer = time.NewTimer(5 * time.Second)
	var timeStop bool
	//timer.Reset(2 * time.Second)
	go func() {
		time.Sleep(1 * time.Second)
		timeStop = timer.Stop()
		if timeStop {
			fmt.Println("炸弹已拆除")
			os.Exit(0)
		}
	}()
	if !timeStop {
		endTime := <-timer.C
		fmt.Println("now is " + endTime.Format(birthTime))
	}
}
